home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / misc-part2 / 10664 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  5.5 KB

  1. Path: news.ottawa.istar.net!usenet
  2. From: Peter_Janes@cableshare.ccmail.compuserve.com (Peter Janes)
  3. Newsgroups: comp.sys.amiga.misc
  4. Subject: Re: AmigaOS 4.x features
  5. Date: Sun, 31 Mar 96 22:26:35 EDT
  6. Organization: Society for the Prevention of Cruelty to Amigas
  7. Message-ID: <5031.6664T1241T611@cableshare.ccmail.compuserve.com>
  8. References: <4j7ein$a6v@B1FF.mindspring.com> <4jc7g1$ipq@news.rhrz.uni-bonn.de>
  9.     <4jfm8i$b5n@B1FF.mindspring.com> <4jgc6q$a61@reuter.cse.ogi.edu> <4jkg5j$dva@B1FF.mindspring.com>
  10. NNTP-Posting-Host: 204.191.69.43
  11. X-Newsreader: THOR 2.22 (Amiga;UUCP) *UNREGISTERED*
  12.  
  13. On 30-Mar-96 18:29:55, Charlie Moody <chmood@photobooks.atdc.gatech.edu> wrote:
  14. > On 29 Mar 1996 09:57:46 GMT, Tony Leneis wrote:
  15. >: In article <4jfm8i$b5n@B1FF.mindspring.com>,
  16.  
  17. > It may be *as* powerful, but not moreso (and what the heck is 'UNIX
  18. > globbing'?)
  19.  
  20. UNIX globbing is another term for UNIX pattern matching, though don't ask
  21. me where the term came from.  It's similar to, but not the same as,
  22. pattern matching via regular expressions (which seems to be what you're
  23. looking for).  (Regular expressions are the most powerful form of pattern
  24. matching, assuming there's a regular pattern to what you're matching,
  25. which is what we're dealing with here.  Apologies to math/CS majors for
  26. a recursive and somewhat imprecise definition, but it's been over a year
  27. since I even *thought* about this stuff.)
  28.  
  29. >: >Not just '?' and '*', but also the bracketed ranging, a la 'mv 
  30. >: >fred-[a-z].pgm ram:'.
  31.  
  32. >:      You can do that now.  Have you ever *tried* it before?  For example:
  33.  
  34. >       [3.1-specific example removed]
  35.  
  36. AFAIK, it was *not* 3.1-specific, but works under V36+....  (Of course, I'm
  37. running on a V40 system, so I can't verify the V37 behaviour.)
  38.  
  39. >: For example, "dir sys:(a|b|c|e)#?".
  40.  
  41. > [additional references to documentation for more counter-intuitive,]
  42. > [anti-logical methods deleted]
  43.  
  44. >               dir sys:[a-e]*
  45.  
  46. > Logical, simple, fast:  elegant.
  47.  
  48. And not a regular expression--that command, if interpreted correctly,
  49. would list *all* of the files on sys:.  (The Kleene star represents 0 or
  50. more occurrences of the term preceding it.)  The regexp form (taking into
  51. account [] vs () translation) would be
  52.     dir sys:[a-e].*
  53.  
  54. And it's not the same as the given example.  Your command includes files
  55. beginning with D, as well.  (BTW, your command works as desired under
  56. AmigaOS--in fact, I just did it.)  Under globbing, the example would be
  57.     dir sys:[a-c|e]*
  58. (which also works under AmigaOS).
  59.  
  60. >: I'd certainly take the functionality of the # operator any day
  61. >: over the UNIX * operator (provided I've got a match-any-character operator
  62. >: to go with it.)
  63.  
  64. > You'd gladly throw away the match-any-character option, provided you've 
  65. > got a match-any-character option to replace it???
  66.  
  67. There are other uses for #; most UN*X-style commands only do globbing, not
  68. regexp, in my experience, so you can't say 'rm ab*c' to remove 'abbc' but
  69. not 'abdc'.  To do this under AmigaOS, 'del a#bc'.
  70.  
  71. There are advantages and disadvantages to both regexps and AmigaOS pattern
  72. matching.  I've had enough theoretical math and computer science to know what
  73. regular expressions can and can't do, and that they're often less than
  74. intuitive.
  75.  
  76. In case it hasn't been mentioned, one of the reasons * isn't activated by
  77. default is that it was also chosen to refer to the console (and as the
  78. escape character).  Assuming it is activated, doing 'dir *' won't give you
  79. a directory of all files, but will produce an error message.  'dir **' will
  80. work properly.  The former behaviour is for compatibility reasons--how do
  81. you tell whether the user is referring to all files or to the console?  The
  82. latter escapes the special meaning of '*-as-console' so that it's read as
  83. '*-as-pattern'.  (Of course, that leads to why * was used as escape instead
  84. of \, and why \ can't be used to continue lines, and why ; is the comment
  85. character instead of the command separator, and why Ctrl-J is the command
  86. separator....)
  87.  
  88. I was about to write that the biggest problem I've had using AmigaOS pattern
  89. matching is that parentheses can't be nested, but decided to try:
  90.     list ram:(*i(p|t)*)
  91. on the following directory:
  92.     Directory "ram:" on Sunday 31-Mar-96
  93.     Disk.info                   1179 ----rw-d Today     17:50:59
  94.     Clipboards                   Dir ----rwed Today     17:50:40
  95.     T                            Dir ----rwed Today     19:55:48
  96.     1 file - 2 directories - 7 blocks used
  97. As expected, it produces:
  98.     Directory "ram:" on Sunday 31-Mar-96
  99.     Clipboards                   Dir ----rwed Today     17:50:40
  100.     1 directory - 2 blocks used
  101. Similarly,
  102.     list ram:(*i~(p|t)*)
  103. produces:
  104.     Directory "ram:" on Sunday 31-Mar-96
  105.     Disk.info                   1179 ----rw-d Today     17:50:59
  106.     1 file - 3 blocks used
  107.  
  108. The latter, using globbing, would be something like:
  109.     list ram:*i~[a-o|q-s|u-z]*
  110.  
  111. This was never meant to become an exhaustive list of globbing, regexp or
  112. AmigaOS pattern matching capabilities, although it seems to have done so. 8^)
  113. Suffice to say, they're different systems.  I believe the Amiga's is more
  114. flexible, simply because it *includes* globbing syntax (including *, although
  115. it's not enabled by default), it includes a slightly modified regexp syntax
  116. (# for .), and it's easier to use, IMHO.
  117.  
  118. Peter_Janes@cableshare.ccmail.compuserve.com | "And so, here we are, victims of
  119.   Network Administrator/QA Specialist    //  |  Mathematics." --Londo Mollari
  120.     Cableshare Interactive Technology  \X/   | *** SUPPORT CANADIAN MUSIC ***
  121.          ex-Certified Amiga Developer -- URL coming soon....
  122.